package com.yue.procress;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yue.bean.json.User;

import java.io.IOException;
import java.util.Map;

/**
 * 功能描述: TODO <br/>
 * 创建时间: 2016/10/8<br/>
 *
 * @author QiuYang
 */
public class GenericBind {
    public static void main(String[] args) {
        readValue();
    }

    public static void readValue(){
        ObjectMapper mapper = new ObjectMapper();

        try {
            Map<String, User> maps = mapper.readValue(
                    GenericBind.class.getClassLoader().getResourceAsStream("many-users.json"),
                    new TypeReference<Map<String, User>>() {});

            User u1 = maps.get("zhangsan");
            System.out.println(u1.getName().getFirst() + "-" + u1.getName().getLast());

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
